package com.orhon.smartcampus.modules.student.entity;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.orhon.smartcampus.modules.user.entity.Users;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "student_eclass_records", schema = "smartcloud", catalog = "")
public class EclassRecords {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    @OneToOne(cascade = CascadeType.ALL , fetch = FetchType.EAGER)
    @JoinColumn(name = "student_id", nullable = false)
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action= NotFoundAction.IGNORE)
    private SInformation student;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name="user_id" ,nullable = false)
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action= NotFoundAction.IGNORE)
    private Users users;

    @OneToOne(cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "original_eclass", nullable = true)
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action=NotFoundAction.IGNORE)
    private Eclass originalEclass;

    @ManyToOne(cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "go_eclass", nullable = true)
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action=NotFoundAction.IGNORE)
    private Eclass goEclass;

    @Column(name = "transaction_type", nullable = true)
    private Integer transactionType;

    @Column(name = "eclass_time", nullable = true)
    private Timestamp eclassTime;

    @Column(name = "reason", nullable = true)
    private String reason;

    @Column(name = "status", nullable = true, length = 50)
    private String status;

    @Column(name = "created_at", nullable = true)
    private Date createdAt;

    @Column(name = "created_by", nullable = true)
    private Integer createdBy;

    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;

    @Column(name = "updated_by", nullable = true)
    private Integer updatedBy;

    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;


}
